<?php
/* @var $this FuncionarioController */
/* @var $model Funcionario */
/* @var $form CActiveForm */
?>

<div class="form">

    <?php
    $form = $this->beginWidget('CActiveForm', array(
        'id' => 'funcionario-form',
        // Please note: When you enable ajax validation, make sure the corresponding
        // controller action is handling ajax validation correctly.
        // There is a call to performAjaxValidation() commented in generated controller code.
        // See class documentation of CActiveForm for details on this.
        'enableAjaxValidation' => false,
    ));
    ?>

    <p class="note">Campos com <span class="required">*</span> são obrigatórios.</p>

    <?php echo $form->errorSummary($model); ?>
    <?php echo $form->errorSummary($pessoa); ?>
    <?php echo $form->errorSummary($usuario); ?>

    <div class="row">
        <span style="float:left; width: 250px;">
            <?php echo $form->labelEx($pessoa, 'nome'); ?>
            <?php echo $form->textField($pessoa, 'nome', array('size' => 60, 'maxlength' => 250)); ?>
            <?php echo $form->error($pessoa, 'nome'); ?>
        </span>

        <span style="float:left; width: 250px;">
            <?php echo $form->labelEx($usuario, 'username'); ?>
            <?php echo $form->textField($usuario, 'username'); ?>
            <?php echo $form->error($usuario, 'username'); ?>
        </span>

        <span style="float:left; width: 150px;">
            <?php echo $form->labelEx($usuario, 'password'); ?>
            <?php echo $form->passwordField($usuario, 'password'); ?>
            <?php echo $form->error($usuario, 'password'); ?>
        </span>
    </div>
    <div class="row">
        <span style="float:left; width: 250px;">
            <?php echo $form->labelEx($model, 'tipo'); ?>
            <?php
            echo $form->dropDownList($model, 'tipo', array('Funcionario' => 'Funcionário',
                'Voluntario' => 'Voluntário'), array('empty' => ''));
            ?>
            <?php echo $form->error($model, 'tipo'); ?>
        </span>

        <span style="float:left; width: 250px;">
            <?php
            $polos = Polo::model()->findAll();
            $polos_id = array();
            foreach ($polos as $polo) {
                $polos_id[$polo->id] = $polo->nome;
            }
            ?>
            <?php echo $form->labelEx($model, 'polo_id'); ?>
            <?php
            echo $form->dropDownList($model, 'polo_id', $polos_id, array('empty' => ''));
            ?>
            <?php echo $form->error($model, 'polo_id'); ?>
        </span>

        <span style="float:left; width: 150px;">
            <?php echo $form->labelEx($pessoa, 'email'); ?>
            <?php echo $form->textField($pessoa, 'email', array('size' => 60, 'maxlength' => 250)); ?>
            <?php echo $form->error($pessoa, 'email'); ?>
        </span>
    </div>       
    <div class="row">
        <span style="float:left; width: 250px;">
            <?php echo $form->labelEx($pessoa, 'cpf'); ?>
            <?php
            $this->widget('CMaskedTextField', array(
                'model' => $pessoa,
                'attribute' => 'cpf',
                'name' => 'cpf_field',
                'mask' => '99999999999',
                'htmlOptions' => array(
                    'style' => 'width:120px;'
                ),
            ));
            ?>
            <?php echo $form->error($pessoa, 'cpf'); ?>
        </span>

        <span style="float:left; width: 250px;">
            <?php echo $form->labelEx($pessoa, 'rg'); ?>
            <?php
            $this->widget('CMaskedTextField', array(
                'model' => $pessoa,
                'attribute' => 'rg',
                'name' => 'rg',
                'mask' => '99999999',
                'htmlOptions' => array(
                    'style' => 'width:100px;'
                ),
            ));
            ?>
            <?php echo $form->error($pessoa, 'rg'); ?>
        </span>

        <span style="float:left; width: 150px;">
            <?php echo $form->labelEx($pessoa, 'data_de_nascimento'); ?>
            <?php
            $this->widget('CMaskedTextField', array(
                'model' => $pessoa,
                'attribute' => 'data_de_nascimento',
                'name' => 'date',
                'mask' => '99/99/9999',
                'htmlOptions' => array(
                    'style' => 'width:100px;'
                ),
            ));
            ?>
            <?php echo $form->error($pessoa, 'data_de_nascimento'); ?>
        </span>
    </div>
    <div class="row">  
        <span style="float:left; width: 250px;">
            <?php echo $form->labelEx($pessoa, 'genero'); ?>
            <?php echo $form->dropDownList($pessoa, 'genero', array('Masculino' => 'Masculino', 'Feminino' => 'Feminino'), array('empty' => '')); ?>
            <?php echo $form->error($pessoa, 'genero'); ?>
        </span>

        <span style="float:left; width: 250px;">
            <?php echo $form->labelEx($pessoa, 'naturalidade'); ?>
            <?php echo $form->textField($pessoa, 'naturalidade', array('size' => 60, 'maxlength' => 45)); ?>
            <?php echo $form->error($pessoa, 'naturalidade'); ?>
        </span>

        <span style="float:left; width: 150px;">
            <?php echo $form->labelEx($pessoa, 'uf'); ?>
            <?php echo $form->textField($pessoa, 'uf'); ?>
            <?php echo $form->error($pessoa, 'uf'); ?>
        </span>

    </div>
    <div class="row">
        <span style="float:left; width: 250px;">
            <?php echo $form->labelEx($pessoa, 'endereco'); ?>
            <?php echo $form->textField($pessoa, 'endereco', array('size' => 60, 'maxlength' => 250)); ?>
            <?php echo $form->error($pessoa, 'endereco'); ?>
        </span>

        <span style="float:left; width: 250px;">
            <?php echo $form->labelEx($pessoa, 'cep'); ?>
            <?php
            $this->widget('CMaskedTextField', array(
                'model' => $pessoa,
                'attribute' => 'cep',
                'name' => 'cep',
                'mask' => '99999999',
                'htmlOptions' => array(
                    'style' => 'width:100px;'
                ),
            ));
            ?>
            <?php echo $form->error($pessoa, 'cep'); ?>
        </span>

        <span style="float:left; width: 150px;">
            <?php echo $form->labelEx($pessoa, 'telefone'); ?>
            <?php echo $form->textField($pessoa, 'telefone', array('size' => 20, 'maxlength' => 20)); ?>
            <?php echo $form->error($pessoa, 'telefone'); ?>
        </span>    
    </div>
    <div class="row">
        <span style="float:left; width: 250px;">
            <?php echo $form->labelEx($pessoa, 'celular'); ?>
            <?php echo $form->textField($pessoa, 'celular', array('size' => 20, 'maxlength' => 20)); ?>
            <?php echo $form->error($pessoa, 'celular'); ?>
        </span>    

        <span style="float:left; width: 250px;">
            <?php echo $form->labelEx($pessoa, 'escolaridade'); ?>
            <?php echo $form->dropDownList($pessoa, 'escolaridade', Pessoa::$escolaridades, array('empty' => '')); ?>
            <?php echo $form->error($pessoa, 'escolaridade'); ?>
        </span>

        <span style="float:left; width: 150px;">
            <?php echo $form->labelEx($pessoa, 'rede_ensino'); ?>
            <?php echo $form->dropDownList($pessoa, 'rede_ensino', Pessoa::$redes_ensino, array('empty' => '')); ?>
            <?php echo $form->error($pessoa, 'rede_ensino'); ?>
        </span>    
    </div>
    <div class="row">
        <span style="float:left; width: 250px;">
            <?php echo $form->labelEx($model, 'pis_pasep'); ?>
            <?php
            $this->widget('CMaskedTextField', array(
                'model' => $model,
                'attribute' => 'pis_pasep',
                'name' => 'pis_pasep',
                'mask' => '99999999999',
                'htmlOptions' => array(
                    'style' => 'width:120px;'
                ),
            ));
            ?>
            <?php echo $form->error($model, 'pis_pasep'); ?>
        </span>   

        <span style="float:left; width: 250px;">
            <?php echo $form->labelEx($model, 'horario'); ?>
            <?php echo $form->textField($model, 'horario', array('size' => 10, 'maxlength' => 4)); ?>
            <?php echo $form->error($model, 'horario'); ?>
        </span>

        <span style="float:left; width: 150px;">
            <?php echo $form->labelEx($model, 'curso_formacao'); ?>
            <?php echo $form->textField($model, 'curso_formacao', array('size' => 60, 'maxlength' => 250)); ?>
            <?php echo $form->error($model, 'curso_formacao'); ?>
        </span>
    </div>
    <div class="row">


        <span style="float:left; width: 250px;">
            <?php echo $form->labelEx($model, 'instituicao_ensino'); ?>
            <?php echo $form->textField($model, 'instituicao_ensino', array('size' => 60, 'maxlength' => 250)); ?>
            <?php echo $form->error($model, 'instituicao_ensino'); ?>
            </scan>

            <span style="float:left; width: 250px;">
                <?php echo $form->labelEx($model, 'observacao'); ?>
                <?php echo $form->textArea($model, 'observacao', array('lines' => 3, 'maxlength' => 250)); ?>
                <?php echo $form->error($model, 'observacao'); ?>
                </scan>
                </div>
                <br/>
                <div class="row buttons">
                    <?php
                    $this->widget('zii.widgets.jui.CJuiButton', array(
                        'buttonType' => 'submit',
                        'name' => 'btnSubmit',
                        'value' => '1',
                        'caption' => $model->isNewRecord ? '  Cadastrar  ' : '   Salvar   ',
                        'htmlOptions' => array('class' => 'ui-button-primary')
                    ));
                    ?>
                </div>

                <?php $this->endWidget(); ?>

                </div><!-- form -->